import request from './request'
export function query ({currentPage = 1, perPage = 10,couponName,type, validatyBegin,validatyEnd} = {}) {
  return request({
    url: '/console/coupon/queryCoupon.do',
    method: 'POST',
    body: {currentPage, perPage,couponName,type, validatyBegin,validatyEnd}
  })
}

export function create ({couponName, type,promAppro,restricted,denomination,num,validatyBegin,validatyEnd,disableDate,useTime,useRule,useNum,couponUsedType,cash,couponType,thirdDesc,thirdType}={}) {
  return request({
    url: '/console/coupon/createCoupon.do',
    method: 'POST',
    body: {couponName, type,promAppro,restricted,denomination,num,validatyBegin,validatyEnd,disableDate,useTime,useRule,useNum,couponUsedType,cash,couponType,thirdDesc,thirdType}
  })
}

export function edit ({couponNo,mchtNo,couponId,couponName, type,promAppro,restricted,denomination,num,validatyBegin,validatyEnd,disableDate,useTime,useRule,useNum,couponUsedType,cash,couponType,thirdDesc,thirdType}={}) {
  return request({
    url: '/console/coupon/updateCoupon.do',
    method: 'POST',
    body: {couponNo,mchtNo,couponId,couponName, type,promAppro,restricted,denomination,num,validatyBegin,validatyEnd,disableDate,useTime,useRule,useNum,couponUsedType,cash,couponType,thirdDesc,thirdType}
  })
}

export function detail (id) {
  return request({
    url: '/console/coupon/getCouponDetil.do',
    method: 'POST',
    body: {id}
  })
}

// 电子券审批
export function queryApplyList ({currentPage = 1, perPage = 10} = {}) {
  return request({
    url: '/console/check/selectApplyList.do',
    method: 'POST',
    body: {currentPage, perPage}
  })
}

export function applydetail (applyNo) {
  return request({
    url: '/console/check/selectApplyDetail.do',
    method: 'POST',
    body: {applyNo}
  })
}

export function checkApply (applyNo) {
  return request({
    url: '/console/check/checkApply.do',
    method: 'POST',
    body: {applyNo}
  })
}

// 获取商品列表
export function queryProlist ({currentPage = 1, perPage = 10,couponNo} = {}) {
  return request({
    url: '/console/coupon/queryProductInfoList.do',
    method: 'POST',
    body: {currentPage, perPage,couponNo}
  })
}

// 关联商品
export function relaPro ({couponNo,productList}={}) {
  return request({
    url: '/console/coupon/updateCouponProductInfo.do',
    method: 'POST',
    body: {couponNo,productList}
  })
}